$(document).ready(function () {
    var backLink = $("#backLink");
    if (backLink.length > 0) {
        if (window.opener || window.dialogArguments) {
            backLink.bind("click", function () {
                closeWindow();
            });
            backLink.text("关闭窗口");
        } else {
            backLink.bind("click", function () {
                goBack();
            });
            backLink.text("返回前页");
        }
    }

    $(document).bind("keypress", function () {
        if ((window.opener || window.dialogArguments) && window.event.keyCode == 27) {
            closeWindow();
        }
    });
});

/**
 * open 500 report window
 */
function openReport500() {
    jQuery.open(contextPath + '/Shared/pages/error/report500.aspx', 700, 410, $("#errorMessage").val());
}

/**
 * save message text
 */
function saveReport500() {
	$("#formForSave").submit();
}

function closeWindow() {
	window.close();
}

function goBack() {
	history.back();
}